package com.humble.vichatbackend.config.datasource;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class DataSourceManager {
    private Map<String,DataSource> dataSourceMap;
    @Autowired
    TeamDataSource teamDataSource;

    @Autowired
    UserDataSource userDataSource;


    @PostConstruct
    private void init(){
        //todo 修改成扫描注解后注入对象；
        dataSourceMap = new HashMap<>();
        dataSourceMap.put("Team",teamDataSource);
        dataSourceMap.put("User",userDataSource);
    }

    public DataSource<?> getDataSource(String type){
        return dataSourceMap.get(type);
    }
}
